package com.itheima.appserver.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * 使用Redis生成唯一ID
 */
@Service
public class IdService {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    public Long createId(String idType) {
        // 对Redis中的key  increment 做自增长
        return this.redisTemplate.opsForValue().increment(idType);
    }
}
